package com.leiduoduo.oms.service;

import com.leiduoduo.oms.dao.ChargebackDao;
import com.leiduoduo.oms.pojo.Chargeback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class ChargebackServiceImpl implements ChargebackService {
    @Autowired
    ChargebackDao chargebackDao;

    @Override
    public boolean addChargeback(Chargeback chargeback) {
        chargeback.setCreated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))
                .setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return chargebackDao.addChargeback(chargeback);
    }

    @Override
    public boolean delChargeback(Chargeback chargeback) {
        chargeback.setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return chargebackDao.delChargeback(chargeback);
    }

    @Override
    public boolean upChargeback(Chargeback chargeback) {
        chargeback.setUpdated_at(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return chargebackDao.upChargeback(chargeback);
    }

    @Override
    public Chargeback getChargebackById(int id) {
        return chargebackDao.getChargebackById(id);
    }

    @Override
    public List<Chargeback> getChargebackList() {
        return chargebackDao.getChargebackList();
    }
}
